<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <div id="app">
    {{ message }}

    <product-item></product-item>

    <home-nav></home-nav>
  </div>
  
  <template id="product">
    <h2>{{ title }}</h2>
    <p>商品描述，限时折扣，赶紧抢购</p>
    <p>价格：{{ price }}</p>
  </template>
  
  <template id="nav">
    <h2>{{ title }}</h2>
    <product-item></product-item>
  </template>

  <script src="../lib/vue.js"></script>
  <script>

    const ProductItem = {
      template: "#product",
      data() {
        return {
          title: "我是product的title",
          price: 9.9
        }
      }
    }

    const app = Vue.createApp({
      components: {
        ProductItem,
        HomeNav: {
          template: "#nav",
          data() {
            return {
              title: "this is nav"
            }
          },
          components: {
            ProductItem,
          }
        }
      },
      data() {
       return {
        message: "hello components"
       }
      }
    })
    app.mount("#app")
  </script>
</body>
</html>